package parser;

import antlr.RecognitionException;
import antlr.Token;

class Slice extends Expr {
    
    Expr left;
    Expr right;
    Expr step;
    
    void delete(ByteStream out) throws RecognitionException {
        throw new RecognitionException("Cannot delete rvalue");
    }
    
    Slice(Expr left,  Expr right, Expr step) {
        if (left != null) {
            this.left = left;
        } else {
            this.left = Expr.NONE;
        }
        if (right != null) {
            this.right = right;
        } else {
            this.right = Expr.NONE;
        }
        if (step != null) {
            this.step = step;
        } else {
            this.step = Expr.NONE;
        }
    }
    
    void write(ByteStream out) throws RecognitionException {
        left.write(out);
        right.write(out);
        step.write(out);
        out.write(Opcodes.SLICE);
    }
    
    void writeLHS(ByteStream out) throws RecognitionException {
        throw new RecognitionException("Cannot assign to slice");
    }
 
}
